﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using Model;
using BLL;
namespace UI
{
    public partial class 房间Upd : Form
    {
        public 房间Upd()
        {
            InitializeComponent();
        }
        主界面 f;
        public 房间Upd(主界面 f)
        {
            InitializeComponent();
            this.f = f;
        }
        private void btnSure_Click(object sender, EventArgs e)
        {
            Model.房间Model.Rname = this.txtRname.Text;
            Model.房间Model.RMount = this.txtRongNa.Text;
            Model.房间Model.RConsume = this.txtDiXiaofei.Text;
            if (checkBox1.Checked == true)
            {
                房间Model.RIsDisCount = "1";
            }
            else
            {
                房间Model.RIsDisCount = "0";
            }

            int count = 房间信息BLL.Update();
            if (count > 0)
            {
                MessageBox.Show("修改成功");
                f.FJ();
                f.SXXXK();
                this.Close();
            }
            else
            {
                MessageBox.Show("修改失败");
            }
                                              
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void 房间Upd_Load(object sender, EventArgs e)
        {
            SqlDataReader dr = 房间信息BLL.Select();
            while (dr.Read())
            {
                this.txtRname.Text = dr[1].ToString();
                this.txtDiXiaofei.Text = dr[2].ToString();
                string dazhe = dr[3].ToString();
                if (dazhe=="True")
                {
                    this.checkBox1.Checked = true;

                }
                else
                {
                    this.checkBox1.Checked = false;
                }
                this.txtRongNa.Text = dr[4].ToString();
            }
        }
    }
}
